package com.example.demo.mapper;

import com.example.demo.entity.Grade;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface GradeMapper {

    @Select("select * from grade")
    List<Grade> selectAll();

    @Select("select * from grade where college=#{college} and grade=#{grade}")
    Grade selectByCollegeAndGrade(@Param("college") String college, @Param("grade") String grade);

    @Select("select * from grade where flag=#{flag}")
    Grade selectByFlag(int flag);

    @Select("select * from grade where college=#{college}")
    List<Grade> selectByCollege(String college);

    @Insert("insert into grade(college,grade) values(#{college},#{grade})")
    int add(Grade grade);

    @Update("update grade set grade=#{grade} where flag=#{flag}")
    int update(Grade grade);

    @Delete("delete from grade where flag=#{flag}")
    int delete(int flag);

    @Insert("<script>insert into grade(college,grade)" +
            "<foreach collection = 'needs' item='record' separator=',' >" +
            " values(#{record.college},#{record.grade})" +
            "</foreach></script>")
    int addMu(@Param("needs") List<Grade> needs);
}
